﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Security.AccessControl;

public partial class Adm_DirectoryInfo : System.Web.UI.Page
{
		protected void Page_Load(object sender, EventArgs e)
		{
				showInfo();
		}
		
		public void showInfo()
		{
		  string info = string.Empty;
				try
				{
				  var dir = Server.MapPath("~");
						List<DirectorySecurity> aclList = null; 

						DirectoryInfo dirInfo = new DirectoryInfo(dir); 
						
						var dirsTrovate = dirInfo.GetDirectories();
						
						info = "Nella directory : "+ dir +" </br>";
						if(dirsTrovate == null) 
						{ info += "Nessuna directory trovata !";return; }
						else
						{
								info += "Tot Directories : "+ dirsTrovate.Length.ToString();
								aclList = new List<DirectorySecurity>(dirsTrovate.Length); 
								
								DirectorySecurity SecurityACL=null;
								
								foreach (var item in dirsTrovate)
								{
										SecurityACL = item.GetAccessControl (AccessControlSections.Access);
										aclList.Add(SecurityACL); 
								}
						}
						LabelInfo.Text = info;

						GridViewACL.DataSource = aclList;
						GridViewACL.DataBind(); 
						
						GridView1.DataSource = dirsTrovate ;
						GridView1.DataBind();  
				}
				catch (Exception ex)
				{
						throw;
				}
				
		}//fM		


		
		
}//fC

